package com.yungu.swift.admin.route.marketing;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.PageVo;
import com.yungu.swift.system.marketing.model.dto.MarketingCouponTemplateDto;
import com.yungu.swift.system.marketing.model.param.AdminCouponTemplatePageParam;
import com.yungu.swift.system.marketing.model.param.AdminCouponTemplateParam;
import com.yungu.swift.system.marketing.service.MarketingCouponTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : cuixiuyin
 * @date : 2019/8/2
 */
@RestController
@RequestMapping("/admin/v1/marketing/coupon/template")
@Api(value = "【营销管理】", tags = "优惠券模板管理")
public class CouponTemplateAdmin {

    @Reference
    private MarketingCouponTemplateService marketingCouponTemplateService;

    @RequestMapping(value = "/queryPage", method = RequestMethod.POST)
    @ApiOperation(value = "优惠券模板分页查询", httpMethod = "POST")
    public ResponseData<PageVo<MarketingCouponTemplateDto>> queryPage(@RequestBody AdminCouponTemplatePageParam templatePageParam) {
        return marketingCouponTemplateService.queryPage(templatePageParam);
    }


    @RequestMapping(value = "/saveOrUpdate", method = RequestMethod.POST)
    @ApiOperation(value = "优惠券模板新增或更新", httpMethod = "POST")
    public ResponseData<Boolean> saveOrUpdate(@RequestBody AdminCouponTemplateParam couponTemplateParam) {
        return marketingCouponTemplateService.saveOrUpdate(couponTemplateParam);
    }
}
